<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/tab.css">
</head>

<body>
    <div class="tab">
        <div class="tab_list">
            <ul>
                <li class="current">商品介绍</li>
                <li>规格与包装</li>
                <li>售后保障</li>
                <li>商品评价</li>
                <li>手机社区</li>
            </ul>
        </div>
        <div class="tab_con">
            <div class="item" style="display: block;">商品介绍模块内容</div>
            <div class="item" style="display: none;">规格与包装模块内容</div>
            <div class="item" style="display: none;">售后保障模块内容</div>
            <div class="item" style="display: none;">商品评价模块内容</div>
            <div class="item" style="display: none;">手机社区模块内容</div>
        </div>
    </div>
    <script>
        var li = document.querySelectorAll('li');
        var item = document.querySelectorAll('.item');
        for (var i = 0; i < li.length; i++) {
            li[i].setAttribute('index', i);
            li[i].onclick = function() {
                for (var i = 0; i < item.length; i++) {
                    li[i].className = '';
                }
                this.className = 'current';
                for (var i = 0; i < item.length; i++) {
                    item[i].style.display = 'none';
                }
                var index = this.getAttribute('index');
                item[index].style.display = 'block';
            }
        }
    </script>
</body>

</html>